﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Yto.Common.Dependency;

namespace Yto.Common.Linq
{
    public class QueryableAsync : IQueryableAsync
    {
        public static QueryableAsync Instance { get; } = new QueryableAsync();

        public Task<int> CountAsync<T>(IQueryable<T> query)
        {
            return Task.FromResult(query.Count());
        }

        public Task<T> FirstOrDefaultAsync<T>(IQueryable<T> query)
        {
            return Task.FromResult(query.FirstOrDefault());
        }

        public Task<List<T>> ToListAsync<T>(IQueryable<T> query)
        {
            return Task.FromResult(query.ToList());
        }
    }
}
